package lan_2021;

import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @Author wly
 * @Create 2023-03-26 17:12
 * @Description:https://www.lanqiao.cn/problems/1449/learning/?page=1&first_category_id=1&sort=students_count&name=%E7%9B%B4%E7%BA%BF
 */
public class Straight_Line {
    public static void main(String[] args) {
        int x, y;
        Scanner scanner = new Scanner(System.in);
        x = scanner.nextInt();
        y = scanner.nextInt();
        scanner.close();
        BigDecimal[][] arr = new BigDecimal[x * x * y * y][2];
        BigDecimal k = new BigDecimal("0");
        BigDecimal b = new BigDecimal("0");
        int m = 0;
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++){
                for (int p = 0; p < x; p++){
                    for (int q = 0; q < y; q++){
                        System.out.println("(" + i + ", " + j + ")" + " - (" + p + ", " + q + ")");
                        if (i == p || j == q){
                            continue;
                        }
                        BigDecimal t1 = new BigDecimal((i - p));
                        BigDecimal t2 = new BigDecimal((j - q));
                        k = t1.divide(t2, 30, BigDecimal.ROUND_HALF_UP);
//                        p + k * (-q)
                        b = new BigDecimal(-q).multiply(k).add(new BigDecimal(p));
                        System.out.println("(" + i + ", " + j + ")" + " - (" + p + ", " + q + ")" + " k = " + k + " b = " + b);
                        arr[m][0] = k;
                        arr[m][1] = b;
                        m++;
                    }
                }
            }
        }
//        System.out.println(m);
//        for (int i = 0; i < m; i++) {
//            System.out.println(arr[i][0] + " " + arr[i][1]);
//        }
        int c = 0, j;
        BigDecimal[][] arr2 = new BigDecimal[m][2];
        for (int i = 0; i < m; i++) {
            for (j = 0; j < c; j++){
                if (arr2[j][0].equals(arr[i][0]) && arr2[j][1].equals(arr[i][1])){
                    break;
                }
            }
            if (j == c){
                arr2[c++] = arr[i];
            }
        }
        System.out.println(c + x + y);
    }
}
